package cn.tedu._05mvcboot01.controller;

import cn.tedu._05mvcboot01.pojo.dto.UserLoginDTO;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;

/*
将此类标注为控制器,用于接受客户端发送的请求
 */
@Controller
public class UserController {
    /**
     * 1.RequestMapping注解:根据请求的URL地址,将请求映射到控制器的方法上
     * 2.ResponseBody注解:将控制器的方法返回值,转换为响应数据,发送给客户端
     * @return
     */
    @RequestMapping("/v1/users/login")
    @ResponseBody
    public String login(){
        return "登陆成功";
    }

    @RequestMapping("/v1/users/reg")
    @ResponseBody
    public String reg(){
        return "注册成功";
    }

    @RequestMapping("/v1/users/login1")
    @ResponseBody
    public String login1(HttpServletRequest request){
        String username=request.getParameter("username");
        String password=request.getParameter("password");

        return username+"_" +password;
    }

    @RequestMapping("/v1/users/login2")
    @ResponseBody
    public  String login2(UserLoginDTO userLoginDTO){
        String username=userLoginDTO.getUsername();
        String password=userLoginDTO.getPassword();
        return username+"-------"+password;
    }
    @RequestMapping("/v1/users/login3")
    @ResponseBody
    public String  login3(String username ,String password){
        return  username +"-------"+ password;

    }




}
